"""
======================
Author: 柠檬班-小简
Time: 2022/10/24 15:25
Project: day4_framwork_V1
Company: 湖南零檬信息技术有限公司
======================
"""
import requests

# 登录
url = 'https://openapiv100.ketangpai.com//UserApi/login'
req_data = {"email":"2501768591@qq.com",
            "password":"yuan5311645",
            "remember":"0",
            "code":"",
            "mobile":"",
            "type":"login",
            "reqtimestamp":1666596279933}
resp = requests.post(url,json=req_data)
result = resp.json()
# 获取token值
token = result["data"]["token"]

# 上传资料 -- 请求头里带token字段
headers = {"token": token}
url = 'https://uploaderv51.ketangpai.com/UploadApi/uploadV2'
req_data = {
    "fileMd5": "fileMd5Computed",
    "chunks": 1,
    "chunk": 0
}
files = {"file": ("33.png", open("../imgs/11.png", "rb"), "image/png")}
resp = requests.post(url, files=files, data=req_data, headers=headers)
result = resp.json()
resource_id = result["data"]["fileid"]

# 提交创建资源接口
url = "https://openapiv100.ketangpai.com//FutureV2/Courseware/create"
req_data = {"courseid":"MDAwMDAwMDAwMLOGvdyHz7tshNtyoQ",
            "title":"33.png",
            "activitylabel":"资料",
            "fullscore":"0",
            "candownload":0,
            "endtime":"",
            "attachment":resource_id,
            "lessonlink":[],
            "id":"",
            "release":0,
            "releasetime":"1666596944",
            "student":{"type":"1","list":["MDAwMDAwMDAwMLOGvdyHz7tshNtyoQ"]},
            "link":"",
            "filetype":[],
            "parent":"MDAwMDAwMDAwMLOGtZeGqaeyhM6GoQ",
            "live_speed":"1",
            "live_progress":"1",
            "live_skiptest":"2",
            "import_id":"",
            "source":"",
            "copyright":"0",
            "reqtimestamp":1666596948686}

resp = requests.post(url, json=req_data, headers=headers)
result = resp.json()
print(result)

